<?php
if(empty($buid))
msg($config['weburl']."/login.php?forward=".urlencode("$config[weburl]/?m=product&s=shop_product_detail&id=".$_GET['id']));
else
{
	include_once("$config[webroot]/module/member/includes/plugin_orderadder_class.php");
	include_once("$config[webroot]/module/logistics/includes/logistics_class.php");
	include_once($config['webroot']."/module/product/includes/plugin_pro_class.php");
	$id = $_GET['id'];
	$order_type = $_GET['order_type'] ?  $_GET['order_type'] : 1;
	$prodetail=new pro();
	$prode=$prodetail->detail($id);


	$p_sql = "select performance_start_time from ".SETMEAL." where pid = '{$prode['pid']}' ";
	$db->query($p_sql);
	$pers= $db->getRows();
	$pers_date = array_unique(array_column($pers,'performance_start_time'));
	$price_sql = "select price,price_desc,stock from ".SETMEAL." where pid = '{$prode['pid']}' and performance_start_time = '{$prode['performance_start_time']}' ";
	$db->query($price_sql);
	$price= $db->getRows();
	$tpl->assign("price",$price);
	$weekarray=array("日","一","二","三","四","五","六");

	foreach($pers_date as $key => $val){
		$pers_dates[$val] = date("Y-m-d",$val).' 周'.$weekarray[date('w',$val)].' '.date("H:i:s",$val);

	}

	$tpl->assign("pers_date",$pers_dates);

	$orderadder=new orderadder();$logistics = new logistics();

	//-----------------------------------------分类
	$sql="select isbuy,ext_table,brand from ".PCAT." where catid='$prode[catid]'";
	$db->query($sql);
	$current_cat=$db->fetchRow();

	//-----------------------------------扩展字段
	include_once("$config[webroot]/module/product/includes/plugin_add_field_class.php");
	$addfield = new AddField('product');
	$prode['extfiled']=$addfield->addfieldinput($prode['pid'],$current_cat['ext_table'],$prode['id']);

	//场馆信息
	if(!empty($prode['spot'])){
		$sql = "select * from ".SPOT." where id = '{$prode['spot']}' ";
		$db->query($sql);
		$prode['spot_detail'] = $db->fetchRow();

	}

	//区域
	$sql = "select * from ".DISTRICT." where pid = 0 ";
	$db->query($sql);
	$prov = $db->getRows();
	$tpl->assign("prov",$prov);

	$cc_sql = "select * from ".CARDCHECK." where uid = '$buid' order by id desc ";
	$db->query($cc_sql);
	$card_check = $db->fetchRow();
	$tpl->assign("card_check",$card_check);

	//配送方式
	$sql = "select id,type,title,`desc` from ".LGSTEMP." where status=1"; //配送方式
	$db->query($sql);
	$ship = $db->getRows();
	foreach($ship as $key=>$val)
	{
		$ship[$key]['price']=$logistics->count_freight($val['id'],'','','');
	}
	$tpl->assign("ship",$ship);

	$tpl->assign("consignee",$orderadder->get_consignee());//收货地址

	//取票地址
	$db->query("select * from ".SINCE." where statu = 1");
	$invoce_address = $db->getRows();
	$tpl->assign("invoce_address",$invoce_address);
}
//=================================================

$tpl->assign("config",$config);
$tpl->assign("current","product");
$tpl->assign('de',$prode);
include_once("footer.php");

$out=tplfetch("shop_product_detail.htm",$flag,true);

?>